﻿#ifndef DOCKWINDOW_H
#define DOCKWINDOW_H

#include <QWidget>
#include <QPropertyAnimation>
#include <QIcon>

namespace Ui {
class DockWindow;
}

enum class StickArea
{
    kTop   ,
    kBottom,
    kLRSide //左右两侧
};

class DockWindow : public QWidget
{
    Q_OBJECT

public:
    explicit DockWindow(QWidget *parent = nullptr);
    ~DockWindow();
    void SetStickArea(StickArea sa,const QPoint& pos);
    void SetPosition(const QPoint& pos);
    void Update();
    void SetSize(const QSize& size);
    void SetExpand();

private:
    Ui::DockWindow *ui;
    void Paint(QPaintEvent* e);
    void Expand();
    void Shrink();
    bool MouseInTitle();
    bool AtRight();
    bool AtLeft();

    std::atomic_bool is_shrinked_{false};
    QSize size_{};
    QPropertyAnimation* expand_geo_{};
    QPropertyAnimation* shrink_geo_{};
    bool mouse_press_titlebar_{false};
    int x_diff_{0};
    int y_diff_{0};
    int layout_type_{0};
    //是否固定，当dock位于左/右侧时，默认不固定，
    //当其位于上/下位置时，将会默认设置为固定位置
    bool is_fixed_{false};
    StickArea stick_area_{StickArea::kLRSide};
    int kDockWidth;
    int opacity_{255};
    QIcon led_on,led_off;

protected:
    bool event(QEvent* event) override;

};

#endif // DOCKWINDOW_H
